home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / STUTTGART / LANG / ADA / GNAT / !gcc / adainc / 4 / ads / i-os2syn < prev    next >
Text File  |  1996-02-12  |  8KB  |  218 lines

  1. ------------------------------------------------------------------------------
  2. --                                                                          --
  3. --                         GNAT COMPILER COMPONENTS                         --
  4. --                                                                          --
  5. --    I N T E R F A C E S . O S 2 L I B . S Y N C H R O N I Z A T I O N     --
  6. --                                                                          --
  7. --                                  S p e c                                 --
  8. --                                                                          --
  9. --                             $Revision: 1.10 $                            --
  10. --                                                                          --
  11. --        Copyright (C) 1993,1994,1995 Free Software Foundation, Inc.       --
  12. --                                                                          --
  13. -- GNAT is free software;  you can  redistribute it  and/or modify it under --
  14. -- terms of the  GNU General Public License as published  by the Free Soft- --
  15. -- ware  Foundation;  either version 2,  or (at your option) any later ver- --
  16. -- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
  17. -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
  18. -- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
  19. -- for  more details.  You should have  received  a copy of the GNU General --
  20. -- Public License  distributed with GNAT;  see file COPYING.  If not, write --
  21. -- to  the Free Software Foundation,  59 Temple Place - Suite 330,  Boston, --
  22. -- MA 02111-1307, USA.                                                      --
  23. --                                                                          --
  24. -- As a special exception,  if other files  instantiate  generics from this --
  25. -- unit, or you link  this unit with other files  to produce an executable, --
  26. -- this  unit  does not  by itself cause  the resulting  executable  to  be --
  27. -- covered  by the  GNU  General  Public  License.  This exception does not --
  28. -- however invalidate  any other reasons why  the executable file  might be --
  29. -- covered by the  GNU Public License.                                      --
  30. --                                                                          --
  31. -- GNAT was originally developed  by the GNAT team at  New York University. --
  32. -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
  33. --                                                                          --
  34. ------------------------------------------------------------------------------
  35.  
  36. with Interfaces.C;
  37. with Interfaces.OS2Lib.Threads;
  38. with System;
  39.  
  40. package Interfaces.OS2Lib.Synchronization is
  41. pragma Preelaborate (Synchronization);
  42.  
  43.    package IC  renames Interfaces.C;
  44.    package IOT renames Interfaces.OS2Lib.Threads;
  45.    package S   renames System;
  46.  
  47.    --  Critical sections
  48.  
  49.    function DosEnterCritSec return APIRET;
  50.    pragma Import (C, DosEnterCritSec, "DosEnterCritSec");
  51.  
  52.    function DosExitCritSec return APIRET;
  53.    pragma Import (C, DosExitCritSec, "DosExitCritSec");
  54.  
  55.    --  Semaphore Attributes
  56.  
  57.    DC_SEM_SHARED : constant := 16#01#;
  58.    --  DosCreateMutex, DosCreateEvent, and DosCreateMuxWait use it to indicate
  59.    --  whether the semaphore is shared or private when the PSZ is null
  60.  
  61.    DCMW_WAIT_ANY : constant := 16#02#;
  62.    --  DosCreateMuxWait option for wait on any event/mutex to occur
  63.  
  64.    DCMW_WAIT_ALL : constant := 16#04#;
  65.    --  DosCreateMuxWait option for wait on all events/mutexes to occur
  66.  
  67.    SEM_INDEFINITE_WAIT  : constant ULONG := -1;
  68.    SEM_IMMEDIATE_RETURN : constant ULONG :=  0;
  69.  
  70.    type HSEM is new System.Address;
  71.    type PHSEM is access all HSEM;
  72.  
  73.    type SEMRECORD is
  74.       record
  75.          hsemCur : HSEM;
  76.          ulUser  : ULONG;
  77.       end record;
  78.    type PSEMRECORD is access all SEMRECORD;
  79.  
  80.  
  81.    type HEV is new IC.unsigned_long;
  82.    type PHEV is access all HEV;
  83.  
  84.    type HMTX  is new IC.unsigned_long;
  85.    type PHMTX is access all HMTX;
  86.  
  87.    type HMUX  is new IC.unsigned_long;
  88.    type PHMUX is access all HMUX;
  89.  
  90.    function DosCreateEventSem
  91.      (pszName   : PSZ;
  92.       f_phev    : PHEV;
  93.       flAttr    : ULONG;
  94.       fState    : BOOL32)
  95.       return      APIRET;
  96.    pragma Import (C, DosCreateEventSem, "DosCreateEventSem");
  97.  
  98.    function DosOpenEventSem
  99.      (pszName   : PSZ;
  100.       F_phev    : PHEV)
  101.       return      APIRET;
  102.    pragma Import (C, DosOpenEventSem, "DosOpenEventSem");
  103.  
  104.    function DosCloseEventSem
  105.      (F_hev     : HEV)
  106.       return      APIRET;
  107.    pragma Import (C, DosCloseEventSem, "DosCloseEventSem");
  108.  
  109.    function DosResetEventSem
  110.      (F_hev     : HEV;
  111.       pulPostCt : PULONG)
  112.       return      APIRET;
  113.    pragma Import (C, DosResetEventSem, "DosResetEventSem");
  114.  
  115.    function DosPostEventSem
  116.      (F_hev     : HEV)
  117.       return      APIRET;
  118.    pragma Import (C, DosPostEventSem, "DosPostEventSem");
  119.  
  120.    function DosWaitEventSem
  121.      (F_hev     : HEV;
  122.       ulTimeout : ULONG)
  123.       return      APIRET;
  124.    pragma Import (C, DosWaitEventSem, "DosWaitEventSem");
  125.  
  126.    function DosQueryEventSem
  127.      (F_hev     : HEV;
  128.       pulPostCt : PULONG)
  129.       return      APIRET;
  130.    pragma Import (C, DosQueryEventSem, "DosQueryEventSem");
  131.  
  132.    function DosCreateMutexSem
  133.      (pszName   : PSZ;
  134.       F_phmtx   : PHMTX;
  135.       flAttr    : ULONG;
  136.       fState    : BOOL32)
  137.       return      APIRET;
  138.    pragma Import (C, DosCreateMutexSem, "DosCreateMutexSem");
  139.  
  140.    function DosOpenMutexSem
  141.      (pszName   : PSZ;
  142.       F_phmtx   : PHMTX)
  143.       return      APIRET;
  144.    pragma Import (C, DosOpenMutexSem, "DosOpenMutexSem");
  145.  
  146.    function DosCloseMutexSem
  147.      (F_hmtx    : HMTX)
  148.       return      APIRET;
  149.    pragma Import (C, DosCloseMutexSem, "DosCloseMutexSem");
  150.  
  151.    function DosRequestMutexSem
  152.      (F_hmtx    : HMTX;
  153.       ulTimeout : ULONG)
  154.       return      APIRET;
  155.    pragma Import (C, DosRequestMutexSem, "DosRequestMutexSem");
  156.  
  157.    function DosReleaseMutexSem
  158.      (F_hmtx    : HMTX)
  159.       return      APIRET;
  160.    pragma Import (C, DosReleaseMutexSem, "DosReleaseMutexSem");
  161.  
  162.    function DosQueryMutexSem
  163.      (F_hmtx    : HMTX;
  164.       F_ppid    : IOT.PPID;
  165.       F_ptid    : IOT.PTID;
  166.       pulCount  : PULONG)
  167.       return      APIRET;
  168.    pragma Import (C, DosQueryMutexSem, "DosQueryMutexSem");
  169.  
  170.    function DosCreateMuxWaitSem
  171.      (pszName   : PSZ;
  172.       F_phmux   : PHMUX;
  173.       cSemRec   : ULONG;
  174.       pSemRec   : PSEMRECORD;
  175.       flAttr    : ULONG)
  176.       return      APIRET;
  177.    pragma Import (C, DosCreateMuxWaitSem, "DosCreateMuxWaitSem");
  178.  
  179.    function DosOpenMuxWaitSem
  180.      (pszName   : PSZ;
  181.       F_phmux   : PHMUX)
  182.       return      APIRET;
  183.    pragma Import (C, DosOpenMuxWaitSem, "DosOpenMuxWaitSem");
  184.  
  185.    function DosCloseMuxWaitSem
  186.      (F_hmux    : HMUX)
  187.       return      APIRET;
  188.    pragma Import (C, DosCloseMuxWaitSem, "DosCloseMuxWaitSem");
  189.  
  190.    function DosWaitMuxWaitSem
  191.      (F_hmux    : HMUX;
  192.       ulTimeout : ULONG;
  193.       pulUser   : PULONG)
  194.       return      APIRET;
  195.    pragma Import (C, DosWaitMuxWaitSem, "DosWaitMuxWaitSem");
  196.  
  197.    function DosAddMuxWaitSem
  198.      (F_hmux    : HMUX;
  199.       pSemRec   : PSEMRECORD)
  200.       return      APIRET;
  201.    pragma Import (C, DosAddMuxWaitSem, "DosAddMuxWaitSem");
  202.  
  203.    function DosDeleteMuxWaitSem
  204.      (F_hmux    : HMUX;
  205.       F_hsem    : HSEM)
  206.       return      APIRET;
  207.    pragma Import (C, DosDeleteMuxWaitSem, "DosDeleteMuxWaitSem");
  208.  
  209.    function DosQueryMuxWaitSem
  210.      (F_hmux    : HMUX;
  211.      pcSemRec   : PULONG;
  212.      pSemRec    : PSEMRECORD;
  213.      pflAttr    : PULONG)
  214.      return       APIRET;
  215.    pragma Import (C, DosQueryMuxWaitSem, "DosQueryMuxWaitSem");
  216.  
  217. end Interfaces.OS2Lib.Synchronization;
  218.